package com.iss.controller.user;

import com.google.gson.Gson;
import com.iss.model.ResponseMessage;
import com.iss.service.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(urlPatterns = "/user/delete")
public class DeleteController extends HttpServlet {

    private UserService service = new UserService();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        Boolean flag=false;
        Gson gson = new Gson();
        ResponseMessage responseMessage = new ResponseMessage();

        String user_Id = req.getParameter("userId");

        Integer userId = Integer.parseInt(user_Id);

        flag= service.remove(user_Id);

        responseMessage.setFlag(flag);

        resp.getWriter().println(gson.toJson(responseMessage));

    }
}
